<admintpl file="header" />
<style>
    .table
    {
        table-layout: fixed;
        width: 100%;
    }
    .table td
    {
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
</style>
</head>
<body style="min-width: 800px;">
<div class="wrap js-check-wrap">
    <ul class="nav nav-tabs">
        <li><a href="{:U('Comment/commentadmin/question_comment_list', array('post_id' => $post_id))}">评论列表</a></li>
        <li class="active"><a>回答列表</a></li>
        <li><a href="{:U('Question/AdminQuestion/invite_professor', array('post_id' => $post_id))}">邀请专栏作者</a></li>
    </ul>
    <table class="table table-hover table-bordered table-list">
        <thead>
        <tr>
            <th width="50">ID</th>
            <th width="100">昵称</th>
            <th>回答内容</th>
            <th width="120">状态</th>
            <th width="120">时间</th>
            <th width="150">操作</th>
        </tr>
        </thead>
        <php>$status = array('0' => '待审核', '1' => '正常');</php>
        <foreach name="answers" item="vo">
            <tr>
                <td>{$vo.id}</td>
                <td>{$vo.post_author_name|default=$vo['user_nicename']}</td>
                <td><a href="{:U('Question/AdminQuestion/overview_question_answer', ['id' => $vo['id']])}" target="_blank">{$vo.real_content}</a></td>
                <td>
                    <select name="post_status" id="post_status" data-id="{$vo.id}" style="width: 120px;">
                        <option value="0" {$vo['post_status'] == 0 ? 'selected' : ''}>{$status[0]}</option>
                        <option value="1" {$vo['post_status'] == 1 ? 'selected' : ''}>{$status[1]}</option>
                    </select>
                </td>
                <td>{$vo.post_date}</td>
                <td>
                    <a href="{:U('Question/AdminQuestion/delete_answer', array('id' => $vo['id']))}" class="js-ajax-delete">删除</a>
                </td>
            </tr>
        </foreach>
    </table>
    <div class="pagination">{$page}</div>
</div>
<script src="__PUBLIC__/js/common.js"></script>
<script type="text/javascript" src="__PUBLIC__/js/layer/layer_1.js"></script>
<script>
    $(document).ready(function () {
        $('body').delegate('#post_status', 'change', function () {
            var id      = $(this).attr('data-id');
            var status  = $(this).val();
            console.log(id, status);
            $.get("{:U('AdminQuestion/update_status')}", {id : id, status : status}, function (data) {
                if (data.status) {
                    layer.msg(data.info);
                }
            })
        })
    })
</script>
</body>
</html>